/**
 * 封装Checkbox
 * @author SPY
 * @date 2020/1/17
 */

import React from 'react';
import PropTypes from 'prop-types';
import { Checkbox } from 'antd';


class MyCheckbox extends React.Component {

    // 定义传入属性
    static propTypes = {
        options: PropTypes.array.isRequired,  // 需要展示的Checkbox数据
    }

    // 定义传入属性的默认值
    static defaultProps = {
        options: [],
        placeholder: '请选择',
    }


    render() {
        const { options, ...restProps } = this.props;
        return (
            <>
                {
                    Array.isArray(options) && options.length > 0 && (
                        <Checkbox.Group
                            options={options}
                            {...restProps}
                        />
                    )
                }
            </>
        );
    }
}

export default MyCheckbox;